package com.bkgy.modular.test.exception;

import com.bkgy.modular.test.entity.ResultVo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ControllerAdvice
public class ExceptionAdvice {
    public static Logger logger = LoggerFactory.getLogger(ExceptionAdvice.class);

    @ResponseBody
    @ExceptionHandler(RuntimeException.class)
    public ResultVo doBusinessException(Exception e) {
        ResultVo resultVo = new ResultVo();
        resultVo.setStatus("-1");
        resultVo.setMessage("运行异常: " + e.getMessage());
        return resultVo;
    }
}
